/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servlets;

import dto.LoggedUser;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Shuvo
 */
public class GetQuestions extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String status = request.getParameter("status");
        String subject = request.getParameter("subject");
        String userId = null;
        String userType = null;
        LoggedUser user = (LoggedUser) request.getSession().getAttribute("user");
        if (user != null) {
            userId = user.getUserId();
            userType = user.getType();
        }
        int page = 1;
        int recordsPerPage = 5;
        if (request.getParameter("page") != null) {
            page = Integer.parseInt(request.getParameter("page"));
        }
        /*FetchQuestions fetchQuestions = new FetchQuestions();
        List<Question> list = fetchQuestions.viewQuestions(status, subject, userId, userType, (page - 1) * recordsPerPage,
                recordsPerPage);
        int noOfRecords = fetchQuestions.getNoOfRecords();
        int noOfPages = (int) Math.ceil(noOfRecords * 1.0 / recordsPerPage);
        System.out.println(list.size());
        request.setAttribute("questionList", list);
        request.setAttribute("noOfPages", noOfPages);
        request.setAttribute("currentPage", page);
        RequestDispatcher view = request.getRequestDispatcher("DisplayQues.jsp");
        view.forward(request, response);*/
    }
}
